<?php

if ( !defined('BLOCK_FILE') ) {
if (stristr(htmlentities($_SERVER['PHP_SELF']), "block-M_Hv3.php")) {
    Header("Location: ../index.php");
    die();
}
}
$module_name = "News";
get_lang($module_name);
$neconfig = ne_get_configs();
global $prefix, $multilingual, $currentlang, $db;

if ($multilingual == 1) {
    $querylang = "WHERE (alanguage='$currentlang' OR alanguage=''";
} else {
    $querylang = "";
}

if ($kategorid == 0) {
if ($querylang !== "") {
    $querylang .= ")";
}
}else{
if ($querylang == "") {
    $querylang = "WHERE (catid='$kategorid')";
}else{
$querylang .= " AND catid='$kategorid')";
}
}

if (!function_exists('filter')) {
function filter($what, $strip="", $save="", $type="") {
stripslashes($what);
return($what);
}
}

$slides = array();

$result = $db->sql_query("SELECT sid, title, hometext, bodytext, haberresim FROM " . $prefix . "_stories $querylang ORDER BY sid DESC LIMIT 0,".$neconfig['gosterilecekhaber']."");
while ($row = $db->sql_fetchrow($result)) {
    $sid = intval($row['sid']);
    $title = filter($row['title'], "nohtml");
    $bodytext = $row[bodytext];
    $haberresim = $row[haberresim];
    $hometext = $row[hometext];
    $habervideo = $row[habervideo];
    array_push($slides, array(
					"slidelink" => "modules.php?name=News&amp;op=NEArticle&amp;sid=$sid",
					"title" => $title,
					"category" => "",
					"tagline" => "",
					"text" => $hometext,
					"slideimage" => $haberresim
		)
	);
}

$content = "";

if ($neconfig['arayuz']=='JJ-Obs' || $neconfig['arayuz']=='JJ-Rasper') { $neconfig['temp_arayuz'] = 1; } else { $neconfig['temp_arayuz'] = 0; }

if (!$neconfig['show_title'] && !$neconfig['show_category'] && !$neconfig['show_slidetext'] && !$neconfig['show_tagline'] && !$neconfig['show_readmore']) {
	$hidecontent = ' style="display:none;"';
} else {
	$hidecontent = '';
}
if($striptags){
	$allowed_tags = "<a><b><span>";
}
if($openlinksexternally){$target = ' target="_blank"';}
if ($neconfig[animasyon]) {$neconfig[animasyon] == 'true';} else {$neconfig[animasyon] == 'false';}

if($random_ordering) {shuffle($slides);}

$html = '';

$step = 1;
if($limitslides) {$i = 0;}

foreach ($slides as $slide) {

	if($limitslides) { if($i>=$limitslides) continue; }

	$slidelink = $slide['slidelink'];
	$slidetitle = $slide['title'];
	$slidecategory = $slide['category'];
	$slidetagline = $slide['tagline'];
	$slidetext = $slide['text'];
	$slideimage = $slide['slideimage'];
	$slidecontent = "\n";

	if ($neconfig['show_title']==1) {
		$slidecontent .= "<h1><a".$target." href=\"".$slidelink."\">".$slidetitle."</a></h1>\n";
	}

	if ($neconfig['show_category']==1) {
		$slidecontent .= "<h2>".$slidecategory."</h2>\n";
	}

	if ($neconfig['show_tagline']==1) {
		$slidecontent .= "<h3>".strip_tags($slidetagline)."</h3>\n";
	}

	if ($striptags) {
		$slidetext = strip_tags($slidetext, $allowed_tags);
	}

	if ($chars) {
		if(function_exists("mb_string")) {
			$slidetext = mb_substr($slidetext, 0, $chars).'...';
			} else {
			$slidetext = substr($slidetext, 0, $chars).'...';
		}
	}

	if (!function_exists('word_limiter')) {
		function word_limiter($str, $limit = 100, $end_char = '&#8230;') {
			  if (trim($str) == '')
			  return $str;
			  preg_match('/\s*(?:\S*\s*){'. (int) $limit .'}/', $str, $matches);
			  if (strlen($matches[0]) == strlen($str)) $end_char = '';
			  return rtrim($matches[0]).$end_char;
		}
	}
	if ($neconfig[words]) {
		$slidetext = word_limiter($slidetext,$neconfig[words]);
	}
	if ($neconfig['show_slidetext']==1) {
		$slidecontent .= "<p>".$slidetext."</p>\n";
	}

	if ($neconfig['show_readmore']==1) {
		$slidecontent .= "<a".$target." href=\"".$slidelink."\" class=\"readon\">"._MORE."</a>\n";
	}
	$html .= '
	<div class="slide">
		<div class="slide-inner">
			<a'.$target.' class="fpss_img" href="'.$slidelink.'">
				<span>
					<span style="background:url('.$slideimage.') no-repeat;">
						<span>
							<img src="'.$slideimage.'" width="'.$neconfig['genislik'].'px" height="'.$neconfig['yukseklik'].'px" alt="'._FPSS_MOD_IMGALT.'" />
   						</span>
					</span>
				</span>
			</a>
			<div class="fpss-introtext"'.$hidecontent.'>
				<div class="slidetext">'.$slidecontent.'</div>
			</div>
		</div>
	</div>
	';

	if($limitslides) {$i++;}
	$step++;
}

$navhtml = '';
$step = 1;
if($limitslides) {$j = 0;}
foreach ($slides as $key => $slide) {
	if($limitslides) {if($j>=$limitslides) continue;}

	$slidelink = $slide['slidelink'];
	$slidetitle = $slide['title'];
	$slidetagline = strip_tags($slide['tagline']);
	$slideimage = $slide['slideimage'];

	$key = $key + 1;
	if ($key < 10) { $key = "".$key; }
	$navhtml .= '
	<li>
		<a class="navbutton off navi" href="javascript:void(0);" title="'._FPSS_MOD_CLICKNAV.'"';
	if ($neconfig[degisimtarzi]=='mouseover') {$navhtml .= ' onclick="parent.location=\''.$slidelink.'\';return false;"';}
	$navhtml .= '>
			<span class="navbar-img"><img src="'.$slideimage.'" alt="'._FPSS_MOD_CLICKNAV.'" /></span>
			<span class="navbar-key">'.$key.'</span>
			<span class="navbar-title">'.$slidetitle.'</span>
			<span class="navbar-tagline">'.$slidetagline.'</span>
			<span class="navbar-clr"></span>
		</a>
	</li>
	';
	if($limitslides) {$j++;}
	$step++;
}

$content .= '<script language="javascript" type="text/javascript">
<!--
var embedFPSSCSS = \'<\' + \'style type="text/css" media="all">\'
+ \'@import "blocks/mh/templates/'.$neconfig['arayuz'].'/template_css.php?w='.$neconfig['genislik'].'&h='.$neconfig['yukseklik'].'&sw='.$neconfig['uncutmenu'].'&kmg='.$neconfig['kmesajgenis'].'&numr='.$neconfig['numararenk'].'&devr='.$neconfig['devamrenk'].'&basr='.$neconfig['baslikrenk'].'&basboy='.$neconfig['baslikboyutu'].'";\'';
if ($neconfig['hide_nav']==1) {$neconfig[uncutmenu] = 0; $content .= '"+ \'#navi-outer {display:none;}\'"'; }
$content .= '+ \'</\' + \'style>\';
document.write(embedFPSSCSS);
-->
</script>';
if (!$neconfig['hide_nav']) {
$content .= '<!--[if lte IE 7]>
<style type="text/css" media="all">
@import "blocks/mh/templates/'.$neconfig['arayuz'].'/template_css_ie.css";
</style>
<![endif]-->';
}
if($optimizejs) {
$content .= '<script language="javascript" type="text/javascript" src="blocks/mh/engines/'.$neconfig['javatipi'].'-fpss.php"></script>';
} else {
if(!$disablelib) {
$content .= "<script language=\"javascript\" type=\"text/javascript\" src=\"blocks/mh/engines/".$neconfig['javatipi']."-comp.js\"></script>\n";
}
$content .= "<script language=\"javascript\" type=\"text/javascript\" src=\"blocks/mh/engines/".$neconfig['javatipi']."-fpss-comp.js\"></script>\n";
}
$content .= '<script language="javascript" type="text/javascript">';
if ($neconfig[javatipi]=='jquery') {
$content .= 'var speed_delay = '.$neconfig['gosterimsuresi'].' ;
var slide_speed = '.$neconfig['gecissuresi'].';
var CTRrotateAction = \''.$neconfig['degisimtarzi'].'\';';
}
if ($neconfig[javatipi]=='mootools') {
$content .= '
var CTRloadingTime = '.$neconfig['yuklemesuresi'].';
var CTRslideInterval = '.$neconfig['gosterimsuresi'].';
var CTRtransitionDuration = '.$neconfig['gecissuresi'].';
var CTRtransitionText = '.$neconfig['degisimsuresi'].';
var CTRrotateAction = \''.$neconfig['degisimtarzi'].'\';
var CTRtext_effect = '.$neconfig['animasyon'].';';
}
$content .= '</script>

<center><div id="fpss-outer-container"';
if ($fpss_css_class) {$content .= ' class="'.$fpss_css_class.'"';}
$content .= '>
    <div id="fpss-container">
        <div id="fpss-slider">
            <div id="slide-loading"></div>
            <div id="slide-wrapper">
                <div id="slide-outer">'.$html.'</div>
            </div>
        </div>
        <div id="navi-outer">
            <div id="pseudobox"></div>
            <div class="ul_container">
                <ul>';
			if ($neconfig['temp_arayuz']) {
                $content .= $navhtml.'
                <li class="noimages"><a id="fpss-container_next" href="javascript:void(0);" onclick="showNext();clearSlide();" title="'._FPSS_MOD_NEXT.'"></a></li>
                <li class="noimages"><a id="fpss-container_playButton" href="javascript:void(0);" onclick="playButtonClicked();return false;" title="'._FPSS_MOD_PLAYPAUSE.'">'._FPSS_MOD_PAUSE.'</a>
                <li class="noimages"><a id="fpss-container_prev" href="javascript:void(0);" onclick="showPrev();clearSlide();" title="'._FPSS_MOD_PREV.'"></a></li>
                <li class="clr"></li>';
            } else {
   $content .= '<li class="noimages"><a id="fpss-container_prev" href="javascript:void(0);" onclick="showPrev();clearSlide();" title="'._FPSS_MOD_PREV.'">&laquo;</a></li>'
		    .$navhtml.'
                <li class="noimages"><a id="fpss-container_next" href="javascript:void(0);" onclick="showNext();clearSlide();" title="'._FPSS_MOD_NEXT.'">&raquo;</a></li>
                <li class="noimages"><a id="fpss-container_playButton" href="javascript:void(0);" onclick="playButtonClicked();return false;" title="'._FPSS_MOD_PLAYPAUSE.'">'._FPSS_MOD_PAUSE.'</a></li>';
            }
   $content .= '</ul>
            </div>
        </div>
    	<div class="fpss-clr"></div>
    </div>
	<div class="fpss-clr"></div>
</div></center>';

?>